package my.jwds.p50;

public class MyPow {


    public static void main(String[] args) {
        MyPow obj = new MyPow();
        System.out.println(obj.myPow(34.00515, Integer.MIN_VALUE));
    }


    public double myPow(double x, int n) {
        return n >=0 ? quickMul(x,n): 1/ quickMul(x,-n);
    }

    public double quickMul(double x,long n){
        if (n == 0){
            return 1;
        }
        double val = quickMul(x,n/2);
        return n%2 == 0? val*val:val*val*x;
    }

}
